package com.huifaapp.mall.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.huifaapp.mall.R;

import java.util.List;

/**
 * Created by 段昱 on 2017/12/12.
 */

public class popwin_adapter extends BaseAdapter {
    private List<String>list;
    private Context context;

    public popwin_adapter(Context context, List<String> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = View.inflate(context,R.layout.itme_tmall_popowingrid,null);
            viewHolder.tvTitle = (TextView) convertView.findViewById(R.id.itme_tmall_popowingrid_text);
            convertView.setTag(viewHolder);// 通过setTag将ViewHolder和convertView绑定
        }  else {
            viewHolder = (ViewHolder) convertView.getTag(); // 获取，通过ViewHolder找到相应的控件
        }
        viewHolder.tvTitle.setText(list.get(position));
        return convertView;
    }
    class ViewHolder {
        TextView tvTitle;
    }
}
